#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int maxn = 105;
int arr[maxn];
int dp1[maxn]; // dp1[i] 表示以 i 结尾的最长上升子序列
int dp2[maxn];
int n;

void solve(){
	cin >> n;
	for (int i=1;i<=n;i++) {
		cin >> arr[i];
	}
	
	for (int i=1;i<=n;i++) {
		dp1[i] = 1;			
		for (int j=i-1;j>=1;j--) {
			if (arr[i] >= arr[j]) {
				dp1[i] = max(dp1[i], dp1[j]+1);
			}
		}
		
	}
	
	for (int i=n;i>=1;i--) {
		dp2[i] = 1;			
		for (int j=i+1;j<=n;j++) {
			if (arr[i] >= arr[j]) {
				dp2[i] = max(dp2[i], dp2[j]+1);
			}
		}
		
	}
	int mn = 105;
	for (int i=1;i<=n;i++) {
		mn = min(mn, n-(dp1[i]+dp2[i]-1));
	}
	cout << mn << '\n';
	
}


signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}
